**Specify your working directory in Stata.
cd c:\data\2022ConsCourt\

**We use "type double" for our data accuracy because double preserves 16 digits of accuracy. As such, do not "compress" our data when replicating our analyses.
set type double
use KimNolettePOPAnalysis, clear

sort iso2 year
save KimNolettePOPAnalysis, replace

tab commonlaw if event~=.
tab VCengage if event~=.
tab dt3yrs if event~=.

summ commonlaw VCengage ///
     polinsur RoverG dt3yrs v2xnp_pres12 lnlatent_gdppcWB22 if event~=.

**Predicted Hazards (Mean and Mode): Model 1 in Table 1 & Figure 3

stset ifinish, failure(event) exit(time .) enter(istart)

stcox commonlaw VCengage ///
      polinsur RoverG dt3yrs v2xnp_pres12 lnlatent_gdppcWB22 ///
	  , cluster(id) efron nohr nolog
      
qui for var commonlaw VCengage ///
      polinsur RoverG dt3yrs v2xnp_pres12 lnlatent_gdppcWB22 ///
      : rename X bk_X

gen commonlaw=0
gen VCengage=0
gen polinsur=.6158447
gen RoverG=.8275698
gen dt3yrs=0
gen v2xnp_pres12=.500781
gen lnlatent_gdppcWB22=23.6715

predict riskscore0, hr
display riskscore0

.32136076

replace commonlaw=0
replace VCengage=0
replace polinsur=.6158447
replace RoverG=.8275698
replace dt3yrs=0
replace v2xnp_pres12=.500781
replace lnlatent_gdppcWB22=23.6715

drop riskscore0
predict riskscore0, hr
display riskscore0

.32136076

**Whenever you change an explanatory variable's value to compute its substantive significance, be sure to undo that change using the corresponding "replace" command above, before computing the next explanatory variable's substantive significance. This is to ensure that the same baseline predicted hazard rate (held at mean and mode) is used in computing each explanatory variable's substantive significance.
**commonlaw 0 to 1
replace commonlaw=1
predict riskscore1, hr
display riskscore1

.05458246

display ((.05458246/.32136076)-1)*100

**As explained above, do not forget to execute "replace commonlaw=0" before computing VCengage's substantive significance.
**VCengage 0 to 1
replace VCengage=1
predict riskscore2, hr
display riskscore2

6.4056027

display ((6.4056027/.32136076)-1)*100

**polinsur mean to max
replace polinsur=1
predict riskscore3a, hr
display riskscore3a

.27563029

**polinsur to min
replace polinsur=0
predict riskscore3b, hr
display riskscore3b

.4110228

display ((.27563029/.4110228)-1)*100

**RoverG mean to max
replace RoverG=6.277778
predict riskscore4a, hr
display riskscore4a

1.1328578

**RoverG to min
replace RoverG=0
predict riskscore4b, hr
display riskscore4b

.2654041

display ((1.1328578/.2654041)-1)*100

**dt3yrs 0 to 1
replace dt3yrs=1
predict riskscore5, hr
display riskscore5

1.2762856

display ((1.2762856/.32136076)-1)*100

**v2xnp_pres12 mean to max
replace v2xnp_pres12=.995
predict riskscore6a, hr
display riskscore6a

.50669118

**v2xnp_pres12 to min
replace v2xnp_pres12=.008
predict riskscore6b, hr
display riskscore6b

.20408813

display ((.50669118/.20408813)-1)*100

**lnlatent_gdppcWB22 mean to max
replace lnlatent_gdppcWB22=30.49819
predict riskscore7a, hr
display riskscore7a

.20600908

**lnlatent_gdppcWB22 to min
replace lnlatent_gdppcWB22=9.411121
predict riskscore7b, hr
display riskscore7b

.81353458

display ((.20600908/.81353458)-1)*100

qui for var commonlaw VCengage ///
      polinsur RoverG dt3yrs v2xnp_pres12 lnlatent_gdppcWB22 ///
      : drop X

qui for any commonlaw VCengage ///
      polinsur RoverG dt3yrs v2xnp_pres12 lnlatent_gdppcWB22 ///
      : rename bk_X X

clear
exit

********************************************************************************
**Replcace commonlaw with civillaw to compute civillaw's substantive significance.
cd c:\data\2022ConsCourt\

set type double
use KimNolettePOPAnalysis, clear

sort iso2 year
save KimNolettePOPAnalysis, replace

**Predicted Hazards (Mean and Mode): Model 1 in Table 1 & Figure 3

stset ifinish, failure(event) exit(time .) enter(istart)

stcox civillaw VCengage ///
      polinsur RoverG dt3yrs v2xnp_pres12 lnlatent_gdppcWB22 ///
	  , cluster(id) efron nohr nolog
      
qui for var civillaw VCengage ///
      polinsur RoverG dt3yrs v2xnp_pres12 lnlatent_gdppcWB22 ///
      : rename X bk_X

gen civillaw=0
gen VCengage=0
gen polinsur=.6158447
gen RoverG=.8275698
gen dt3yrs=0
gen v2xnp_pres12=.500781
gen lnlatent_gdppcWB22=23.6715

predict riskscore0, hr
display riskscore0

.32136076

replace civillaw=0
replace VCengage=0
replace polinsur=.6158447
replace RoverG=.8275698
replace dt3yrs=0
replace v2xnp_pres12=.500781
replace lnlatent_gdppcWB22=23.6715

drop riskscore0
predict riskscore0, hr
display riskscore0

.32136076

**civillaw 0 to 1
replace civillaw=1
predict riskscore1, hr
display riskscore1

1.8920499

display ((1.8920499/.32136076)-1)*100

qui for var civillaw VCengage ///
      polinsur RoverG dt3yrs v2xnp_pres12 lnlatent_gdppcWB22 ///
      : drop X

qui for any civillaw VCengage ///
      polinsur RoverG dt3yrs v2xnp_pres12 lnlatent_gdppcWB22 ///
      : rename bk_X X

clear
exit
